 
 	<?php
		function set_val($obj, $val, $return='echo')
		{
			if(isset($obj))
				if(isset($obj->$val))
					if($return=='echo')
						echo($obj->$val);
					else
						return $obj->$val;
		}
	?>
 
 <link rel="stylesheet" href="<?php echo $this->config->item('css')?>/jquery.multiselect.css"> <!--  -->
 <link rel="stylesheet" href="<?php echo $this->config->item('css')?>/jquery.multiselect.filter.css"> <!--  -->

<script src="<?php echo $this->config->item('js')?>/jquery.multiselect.min.js"></script>
<script src="<?php echo $this->config->item('js')?>/jquery.multiselect.filter.js"></script>


				<div><br>
					<form id="form" class="block-content form" action="<?php echo site_url('company/save')?>" method="post">
						<input type="hidden" id="id" name="id" value="<?php set_val($company,'id')?>" />
						<div class="_100">
							<p><label for="textfield">Company Name</label>
							<input id="name" name="name" class="required" type="text" value="<?php set_val($company,'name')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="country">Country</label>
							<select name="country" id="country" class="required">
								<option value="">Select Country</option>
								<?php foreach($this->config->item('en_countries') as $key=>$value):?>
									<option <?php if(set_val($company,'country','return')==$key) echo 'selected="selected"';?> value="<?php echo $key?>"><?php echo $value?></option>
								<?php endforeach;?>
							</select>
							</p>
						</div>
						
						<div class="_50">
							<p><label for="city">City</label><input id="city" name="city" class="required" type="text" value="<?php set_val($company,'city')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="phone1">Phone 1</label><input id="phone1" name="phone1" class="required" type="text" value="<?php set_val($company,'phone1')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="phone2">Phone 2</label><input id="phone2" name="phone2" class="" type="text" value="<?php set_val($company,'phone2')?>" /></p>
						</div>
						
						<div class="_100">
							<p><label for="phone3">Phone 3</label><input id="phone3" name="phone3" class="" type="text" value="<?php set_val($company,'phone3')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="fax1">Fax 1</label><input id="fax1" name="fax1" class="" type="text" value="<?php set_val($company,'fax1')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="fax2">Fax 2</label><input id="fax2" name="fax2" class="" type="text" value="<?php set_val($company,'fax2')?>" /></p>
						</div>
						
						<div class="_100">
							<p><label for="email">Company Email</label><input id="email" name="email" class="email" type="text" value="<?php set_val($company,'email')?>" /></p>
						</div>
						
						<div class="_100">
							<p><label for="website">Website</label><input id="website" name="website" class="" type="text" value="<?php set_val($company,'website')?>" /></p>
						</div>
						
						<div class="_100">
							<p><label for="address1">Address 1</label><textarea id="address1" name="address1" class="required" rows="3" cols="40"><?php set_val($company,'address1')?></textarea></p>
						</div>
						
						<div class="_100">
							<p><label for="address2">Address 2</label><textarea id="address2" name="address2" class="" rows="3" cols="40"><?php set_val($company,'address2')?></textarea></p>
						</div>
						
						<div class="_100">
							<p><label for="notes">Notes</label><textarea id="notes" name="notes" class="" rows="2" cols="40"><?php set_val($company,'notes')?></textarea></p>
						</div>
						
						

						<div class="clear"></div>
						<div class="block-actions">
							<ul class="actions-left">
								<li><a class="button red" id="reset-validate-form" href="javascript:void(0);">Reset</a></li>
							</ul>
							<ul class="actions-right">
								<li><input type="submit" class="button" value="Save!"></li>
							</ul>
						</div>
					</form>

				</div>
				
				
				<script type="text/javascript">
						
		
	$().ready(function() {
		
		$("#country").multiselect({
		   multiple: false,
		   header: "Select an option",
		   noneSelectedText: "Select an Option",
		   selectedList: 1,

		   maxWidth: 300,
		   show: "slide",
		   hide: "slide"

		}).multiselectfilter();
		
		$("button.ui-multiselect").css('width','200px');
		$(".ui-multiselect-menu").css('width','285px');
		
		/** Submit Form **/
		$("#form").validate({
				rules:{},
				messages: {},
				submitHandler: function(form) {
				   //submit
				$.post("<?php echo site_url('company/save')?>", $("#form").serialize(),
					function(data){
						if(data){
							
							newdata = $.parseJSON(data);
							
							if(newdata.error){
								Gtheme = 'error';
								
								$.each(newdata.msg, function(index) {
									$.jGrowl(newdata.msg[index], { theme: Gtheme,position:'center'  });
								});

							}
							else{
								Gtheme = 'saved';
								$.jGrowl(newdata.msg, { theme: Gtheme,position:'center'  });
								$('.a-z-list').parent().children('.block-content').slideToggle();
								a_z_list();
								temp_id = $("#id").val();
								//clear the folrm
									$("#id").val('');
									$(":input").not(":button, :submit, :reset, :hidden").each(function () {
										this.value = '';
									});
									if(newdata.id>0)
										load_info(newdata.id);
									else
										load_info(temp_id);
							}

						}
						else{
							$.jGrowl("Error!", { theme: 'error' });
						}
					});
				}
			});
		/** End Submit Form **/
		
		});
		
		
    </script>
				
				
				</script>
